#pragma once

#include <gst/gst.h>
#include <nvdsmeta.h>
#include <cstdint>
#include <gstnvdsmeta.h>
#include <opencv2/opencv.hpp>
#include <vector>

enum TIMESTAMP_TYPE : uint8_t {
    LANDING_TIME = 0, // 数据落地时间戳
    DETECTION_TIME,   // 检测完成时间戳
};

class NVDSCustomMeta
{
public:
    NVDSCustomMeta();
    ~NVDSCustomMeta();

private:
    static gpointer gstCopy(gpointer data, gpointer user_data);
    static void     gstRelease(gpointer data, gpointer user_data);
    static gpointer gstToNvdsTransform(gpointer data, gpointer user_data);
    static gpointer nvdsCopy(gpointer data, gpointer user_data);
    static void     nvdsRelease(gpointer data, gpointer user_data);

public:
    static NvDsMetaType getType();
    void                gstBufferAddMeta(GstBuffer *buf);

    std::map<TIMESTAMP_TYPE, uint64_t> &timestamp()
    {
        return m_timestamp;
    }

    std::vector<uint8_t> &imgBuffer()
    {
        return m_imgBuffer;
    }

    const cv::Size &getImageSize() const
    {
        return m_imgSize;
    }

    void setImageSize(int width, int height)
    {
        m_imgSize.width  = width;
        m_imgSize.height = height;
    }

private:
    std::map<TIMESTAMP_TYPE, uint64_t> m_timestamp; // 阶段时间戳
    std::vector<uint8_t>               m_imgBuffer; // 图像数据
    cv::Size                           m_imgSize;   // 图像尺寸
};
